home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
ZISUBCD.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-09
|
4KB
|
110 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: zn.cpp
// Title: Zinc Window Template
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
// This module contains code for the class ZI_SUBSCRIBE.
//
// The code in this module may be written in C++ or C.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
//
//----------------------------------------------------------------------------
#include <zi.hpp>
//----------------------------------------------------------------------------
// Globals
//----------------------------------------------------------------------------
static PCSZ apszSuffix[MAX_SUBSCRIBE_LEVEL] = { "-5", "-10", "-15", "-20" };
static PCSZ pcszKey = "9-Digit ZIP Disc";
//----------------------------------------------------------------------------
// Description: Generate a code for renewing the subscription.
// Parameters:
// Returns:
//----------------------------------------------------------------------------
VOID FN_E SubscribeGenerate(SHORT sLevel, PSZ psz)
{
QueryGenerate(psz);
Assert(sLevel >= 0 && sLevel <= MAX_SUBSCRIBE_LEVEL);
strcat(psz, apszSuffix[sLevel]);
return ;
}
//----------------------------------------------------------------------------
// Description: Generate a response for renewing the subscription.
// Parameters:
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E SubscribeResponse(PCSZ pcszCode, PSZ pszResponse)
{
Assert(strlen(pcszCode) >= 8);
for (SIZET i = 0; i < MAX_SUBSCRIBE_LEVEL; ++i)
if (strcmp(pcszCode + 8, apszSuffix[i]) == 0)
break;
if (i >= MAX_SUBSCRIBE_LEVEL)
{
Error("Invalid inquiry code.");
return FALSE;
}
strcpy(pszResponse, pcszCode);
pszResponse[8] = '\0';
QueryResponse(pszResponse, pcszKey);
strcat(pszResponse, apszSuffix[i]);
return TRUE;
}
//----------------------------------------------------------------------------
// Description: Generate a response for renewing the subscription.
// Parameters:
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E SubscribeVerify(PCSZ pcszInput, PCSZ pcszResponse)
{
CHAR szResponse[20];
CHAR szInput[20];
strcpy(szResponse, pcszResponse);
strcpy(szInput, pcszInput);
if (strcmp(szInput + 8, szResponse + 8) != 0)
return FALSE;
szResponse[8] = '\0';
szInput[8] = '\0';
return QueryVerify(szInput, szResponse, pcszKey);
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------